#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m;
ll a[N], d[N], bit[N], kbit[N];
int lowbit(int x) { return x & -x; }
void update(int x, ll k) {
  for (int i = x; i <= n; i += lowbit(i)) {
    bit[i] += k;
    kbit[i] += k * x;
  }
}
ll query(int x) {
  ll ksum = 0, sum = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    ksum += kbit[i];
    sum += bit[i];
  }
  return sum * (x + 1) - ksum;
}
void init() {
  rep(i, 1, n) d[i] = a[i] - a[i - 1];
  rep(i, 1, n) update(i, d[i]);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  init();
  while (m--) {
    ll op, x, y, k;
    cin >> op >> x >> y;
    if (op == 1) {
      cin >> k;
      update(x, k), update(y + 1, -k);
    } else {
      cout << query(y) - query(x - 1) << endl;
    }
  }
  return 0;
}